﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using KerriganDirection.DirectionServiceWCF;

namespace KerriganDirection.VehicleMgt
{
    /// <summary>
    /// Interaction logic for AddVehicle.xaml
    /// </summary>
    public partial class ucAddVehicle : UserControl, INotifyPropertyChanged
    {
        #region NotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

        #endregion

        #region Properties

        private MainModule _MainModuleVO;
        public MainModule MainModuleVO
        {
            get
            {
                return this._MainModuleVO;
            }
            set
            {
                this._MainModuleVO = value;
                OnPropertyChanged("MainWindowVO");
            }
        }

        #endregion

        #region Contructors

        public ucAddVehicle()
        {
            this.MainModuleVO = (App.Current.Windows[0] as MainWindow).MainModuleVO;

            InitProperties();

            InitializeComponent();

            //Add default value
            this.MainModuleVO.VehicleModuleVO.VehicleVO.LastRevision = DateTime.Now;

            LoadComboBox();
        }

        #endregion

        #region Methods

        public void InitProperties()
        {
            //Initialization Virtual Object
            this.MainModuleVO.VehicleModuleVO.VehicleVO = new VehicleDC();
            this.MainModuleVO.VehicleModuleVO.VehicleVO.TypeVehicle = new TypeVehicleDC();
        }

        public void LoadComboBox()
        {
            //DataContext
            this.DataContext = this.MainModuleVO.VehicleModuleVO.VehicleVO;
            this.cbTypeVehicle.DataContext = this.MainModuleVO.VehicleModuleVO.VehicleVO.TypeVehicle;

            //ItemsSource
            this.cbTypeVehicle.ItemsSource = this.MainModuleVO.VehicleModuleVO.ListTypeVehicleVO;
        }

        #endregion

        #region Events

        #endregion
    }
}
